/*
 * Messaggi ipc
 */
#include "message.h"
#include "syscall.h"
#include <libc/ctype.h>
#include "task.h"
#include "regs.h"

/*
 * Riceve un messaggio
 */
int message_recv(message_t *m)
{
	regs_t r;
	r.eax = MSG_RECV;
	r.ebx = (int) m->data;
	r.ecx = (int) &m->pid;
	
	m->size = (unsigned) syscall_call(r);
	
	return (int) m->size;
}

/*
 * Invia un messaggio
 */
int message_send(message_t *m)
{
	regs_t r;
	r.eax = MSG_SEND;
	r.ebx = m->pid;
	r.ecx = (int) m->data;
	r.edx = m->size;
	
	return (int) syscall_call(r);
}
